<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <title>Thymeleaf tutorial: exercise 9</title>
        <link rel="stylesheet" href="../../../css/main-static.css" th:href="@{/css/main.css}" />
        <meta charset="utf-8" />
    </head>
    <body>
        <h1>Thymeleaf tutorial - Solution for exercise 9: more on conditions</h1>
        <h2>Customer list</h2>
        <table>
            <thead>
                <tr>
                    <th>First name</th>
                    <th>Last name</th>
                    <th>Gender</th>
                    <th>Payment method</th>
                    <th>Balance</th>
                </tr>
            </thead>
            <tbody th:remove="all-but-first">
                <tr th:each="customer : ${customerList}">
                    <td th:text="${customer.firstName}">Peter</td>
                    <td th:text="${customer.lastName}">Jackson</td>
                    <td th:switch="${customer.gender?.name()}">
                        <img th:case="'MALE'" src="../../../male.png" th:src="@{/male.png}" alt="Male" />
                        <img th:case="'FEMALE'" src="../../../female.png" th:src="@{/female.png}" alt="Female" />
                        <span th:case="*">Unknown</span>
                    </td>
                    <td>
                        <span th:text="${customer.paymentMethod.description}">Direct debit</span>
                        <span th:unless="${customer.paymentMethod.name() == 'CREDIT_CARD'}" class="warn">
                            Payment must be done in the next 4 days
                        </span>
                    </td>
                    <td th:class="${customer.balance gt 10000} ? 'enhanced'" th:text="${customer.balance}">350</td>
                </tr>
                <tr>
                    <td>Mary</td>
                    <td>Johanson</td>
                    <td><img src="../../../female.png" /></td>
                    <td><span>Credit card</span></td>
                    <td>5000</td>
                </tr>
                <tr>
                    <td>Robert</td>
                    <td>Allen</td>
                    <td><img src="../../../male.png" /></td>
                    <td>
                        <span>Credit card</span>
                        <span class="warn">Payment must be done in the next 4 days</span>
                    </td>
                    <td class="enhanced">50000</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
